<template>
  <el-card style="margin: 14px">
    <div v-if="authUser">
      <el-form ref="enterpriseForm" :model="enterpriseForm" label-width="80px">
        <el-form-item label="油企名称" prop="enterpriseId">
          <el-select
            v-model="enterpriseForm.enterpriseId"
            placeholder="请选择油企"
            size="small"
          >
            <el-option label="油企1" value="1"></el-option>
            <el-option label="油企2" value="2"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </div>
    <div class="title">
      <div>今日经营情况</div>
      <el-divider></el-divider>
    </div>
    <el-row
      :gutter="20"
      v-for="(i, index) in lists"
      :key="index"
      class="row-mg-t12"
    >
      <el-col
        :span="5.5"
        v-for="(j, jndex) in i"
        :key="jndex"
        class="col-center"
      >
        <el-tooltip placement="top">
          <div
            style="max-width: 80vw"
            v-html="ToBreak(j.name + j.value)"
            slot="content"
          ></div>
          <div class="oneLine">
            <span class="line"> {{ j.name }}{{ j.value }} </span>
            <span class="unit">{{ j.unit }}</span>
          </div>
        </el-tooltip>
        <el-divider
          v-if="jndex < 5 && i.length != jndex + 1"
          direction="vertical"
        ></el-divider>
      </el-col>
    </el-row>
    <div class="title" style="margin-top: 26px">
      <div>历史经营数据</div>
      <el-divider></el-divider>
    </div>
    <div>
      <el-form ref="dateForm" :model="dateForm" label-width="80px">
        <el-form-item label="日期选择">
          <el-date-picker
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            size="small"
          >
          </el-date-picker>
          <div style="display: inline-block; margin-left: 12px">
            <el-button type="primary" size="mini">搜索</el-button>
            <el-button type="primary" size="mini">导出</el-button>
          </div>
        </el-form-item>
      </el-form>
    </div>
    <el-table :data="tableData" style="width: 100%" height="400" stripe>
      <el-table-column label="日期" width="120"> </el-table-column>
      <el-table-column label="提现总金额(元)" width="120"> </el-table-column>
      <el-table-column label="手续费(元)" width="120"> </el-table-column>
      <el-table-column label="加油应付金额(元)" width="120"> </el-table-column>
      <el-table-column label="加油优惠金额(元)" width="120"> </el-table-column>
      <el-table-column label="加油余额支付" width="120"> </el-table-column>
      <el-table-column label="加油提现金额(元)" width="120"> </el-table-column>
      <el-table-column label="非油应付金额(元)" width="120"> </el-table-column>
      <el-table-column label="非油优惠金额(元)" width="120"> </el-table-column>
      <el-table-column label="非油提现金额(元)" width="120"> </el-table-column>
      <el-table-column label="非油使用积分" width="120"> </el-table-column>
      <el-table-column label="充值金额(元)" width="120"> </el-table-column>
      <el-table-column label="充值赠送金额(元)" width="120"> </el-table-column>
      <el-table-column label="充值提现金额(元)" width="120"> </el-table-column>
      <el-table-column label="收款码优惠金额(元)" width="120">
      </el-table-column>
      <el-table-column label="收款码提现金额(元)" width="120">
      </el-table-column>
      <el-table-column label="现金收款(元)" width="120"> </el-table-column>
      <el-table-column label="获得积分" width="120"> </el-table-column>
    </el-table>
    <div style="text-align: right; margin-top: 8px">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[100, 200, 300, 400]"
        :page-size="100"
        layout="total, sizes, prev, pager, next, jumper"
        :total="400"
      >
      </el-pagination>
    </div>
  </el-card>
</template>
<script>
export default {
  data() {
    return {
      enterpriseForm: {},
      dateForm: {},
      currentPage: 1,
      lists: [
        [
          {
            key: "test1",
            name: "加油应付金额：",
            value: "123",
            unit: "元",
          },
          {
            key: "test2",
            name: "加油应付金额：",
            value: "6666",
            unit: "元",
          },
          {
            key: "test3",
            name: "加油应付金额：",
            value: "777",
            unit: "元",
          },
          {
            key: "test4",
            name: "加油应付金额：",
            value: "123122122223125435043696856",
            unit: "元",
          },
        ],
        [
          {
            key: "test5",
            name: "加油应付金额：",
            value: "123",
            unit: "元",
          },
          {
            key: "test6",
            name: "加油应付金额：",
            value: "6666",
            unit: "元",
          },
          {
            key: "test7",
            name: "加油应付金额：",
            value: "777",
            unit: "元",
          },
          {
            key: "test8",
            name: "加油应付金额：",
            value: "123122122223125435043696856",
            unit: "元",
          },
        ],
        [
          {
            key: "test9",
            name: "加油应付金额：",
            value: "123",
            unit: "元",
          },
          {
            key: "test10",
            name: "加油应付金额：",
            value: "6666",
            unit: "元",
          },
          {
            key: "test11",
            name: "加油应付金额：",
            value: "777",
            unit: "元",
          },
          {
            key: "test12",
            name: "加油应付金额：",
            value: "123122122223125435043696856",
            unit: "元",
          },
        ],
        [
          {
            key: "test13",
            name: "加油应付金额：",
            value: "123",
            unit: "元",
          },
          {
            key: "test14",
            name: "加油应付金额：",
            value: "6666",
            unit: "元",
          },
          {
            key: "test15",
            name: "加油应付金额：",
            value: "777",
            unit: "元",
          },
          {
            key: "test16",
            name: "加油应付金额：",
            value: "123122122223125435043696856",
            unit: "元",
          },
        ],
      ],
      tableData: [],
      data: {
        test1: 1,
        test2: 2,
        test3: 3,
        test4: 4,
        test5: 5,
        test6: 6,
        test7: 7,
        test8: 8,
        test9: 9,
        test10: 10,
        test11: 11,
        test12: 12,
        test13: 13,
        test14: 14,
        test15: 15,
        test16: 16,
      },
    };
  },
  created() {
    this.assignKey();
  },
  methods: {
    ToBreak(val) {
      return val.replaceAll(",", "<br />");
    },
    assignKey() {
      this.lists.map((item, index) => {
        item.map((jtem, jndex) => {
          Object.keys(this.data).forEach((key) => {
            if (jtem.key == key) {
              jtem.value = this.data[key];
            }
          });
        });
      });
    },
    handleSizeChange() {},
    handleCurrentChange() {},
  },
  computed: {
    authUser() {
      let roles = this.$store.state.user.roles;
      if (roles.includes("admin")) {
        return true;
      } else {
        return false;
      }
    },
  },
};
</script>
<style scoped>
.oneLine {
  width: 90%;
  display: flex;
}

.line {
  max-width: 90%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.col-center {
  display: flex;
  align-items: center;
}

.row-mg-t12 {
  margin: 12px 0;
}

.unit {
  color: #01a7f0;
  margin-left: 6px;
}
.title {
  font-size: 20px;
  font-weight: 500;
}
</style>
